package com.dormitoryAdministratorSystem.ui.studentmanage;

import com.dormitoryAdministratorSystem.entity.student.StudentBean;
import com.dormitoryAdministratorSystem.service.student.impl.StudentSerImpl;
import com.dormitoryAdministratorSystem.ui.MainFrame;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoLabel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

public class StudentShowDialog extends JDialog {
	
	private LovoLabel nameLab;
	private LovoLabel genderLab;
	private LovoLabel classLab;
	private LovoLabel roomLab;
	private JLabel headPicLab;
	private LovoLabel stuTelLab;
	private LovoLabel stuInTimeLab;
	
	private LovoButton okBtn;
	private StudentBean s1;

	private  int id;
	StudentSerImpl ssi = new StudentSerImpl();
	
	public StudentShowDialog(MainFrame frame, int id) {
		// TODO Auto-generated constructor stub
		super(frame, "添加学生", true);
		this.id = id;
		this.setBounds(350, 250, 500, 400);
		this.setLayout(null);
		this.init();

		this.setVisible(true);
	}

	private void init() {
		// TODO Auto-generated method stub
		this.nameLab = new LovoLabel("姓名", 20, 40, this);
		this.genderLab = new LovoLabel("性别",20, 120, this);
		this.classLab = new LovoLabel("班级",20, 200, this);
		this.roomLab = new LovoLabel("房间", 20, 260, this);

		StudentBean s = ssi.showStuInfo(this.id);
		this.s1 = s;
		this.nameLab.setText(s.getSName());
		this.genderLab.setText(s.getGender());
		this.classLab.setText(s.getClassBean().getCName());
		this.roomLab.setText(s.getRoomBean().getAddress());
		
		this.headPicLab = new JLabel();
		this.headPicLab.setBounds(300, 40, 100, 150);
		this.add(this.headPicLab);
		
		this.stuTelLab = new LovoLabel("联系电话",250, 200, this);
		this.stuInTimeLab = new LovoLabel("入住时间",250, 260, this);
		this.stuTelLab.setText(s.getPhoneNum());
		this.stuInTimeLab.setText(s.getSTime().toString());
		
		this.okBtn = new LovoButton("确定", 180, 320, this);



		this.okBtn.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				StudentShowDialog.this.dispose();
			}
		});
	}

	@Override
	public void paint(Graphics g) {
		super.paint(g);
		g.drawImage(new ImageIcon("E:\\IdeaProjects\\dormitory_mamagement\\photo" +
						File.separator + s1.getPhotoPath()).getImage(), 270,
				70, 100, 150, null
				);
	}
}
